package com.daotingli.backendprograms.Repository.Retriever;

import com.daotingli.backendprograms.DB.SpringDB;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class RetrieverRepository {
    @Autowired
    private SpringDB springDB;

    public Map Retriever(String username, String password, String identity, String userphone) {
        JdbcTemplate jdbcTemplate=springDB.getJdbcTemplate();
            // 根据手机号和用户名称和身份 修改用户密码
        String sql="update t_user set password=? where username=? and identity=? and userphone=?";
        int count=jdbcTemplate.update(sql,password,username,identity,userphone);
        Map map=new HashMap();
        if(count>0)
        {
            map.put("code",200);
            map.put("msg","修改成功");
            map.put("data",count);
        }
        else {
            map.put("code",400);
            map.put("msg","修改失败");
            map.put("data",count);
        }
        return map;
    }
}
